<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>药品识别系统</title>
    
    <!-- Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Font Awesome -->
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
    
    <style>
        body {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }
        
        .navbar {
            background: rgba(255, 255, 255, 0.95) !important;
            backdrop-filter: blur(10px);
            box-shadow: 0 2px 20px rgba(0,0,0,0.1);
        }
        
        .main-container {
            margin-top: 80px;
            padding: 20px;
        }
        
        .card {
            border: none;
            border-radius: 15px;
            box-shadow: 0 10px 30px rgba(0,0,0,0.1);
            backdrop-filter: blur(10px);
            background: rgba(255, 255, 255, 0.9);
        }
        
        .btn-primary {
            background: linear-gradient(45deg, #667eea, #764ba2);
            border: none;
            border-radius: 25px;
            padding: 10px 30px;
            transition: all 0.3s ease;
        }
        
        .btn-primary:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(0,0,0,0.2);
        }
        
        .feature-card {
            transition: all 0.3s ease;
            cursor: pointer;
        }
        
        .feature-card:hover {
            transform: translateY(-5px);
        }
        
        .hero-section {
            text-align: center;
            padding: 60px 0;
            color: white;
        }
        
        @media (max-width: 768px) {
            .main-container {
                margin-top: 70px;
                padding: 10px;
            }
            
            .hero-section {
                padding: 40px 0;
            }
        }
    </style>
</head>
<body>
    <!-- Navigation -->
    <nav class="navbar navbar-expand-lg navbar-light fixed-top">
        <div class="container">
            <a class="navbar-brand fw-bold" href="/">
                <i class="fas fa-pills text-primary me-2"></i>药品识别系统
            </a>
            
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
                <span class="navbar-toggler-icon"></span>
            </button>
            
            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav ms-auto">
                    <li class="nav-item">
                        <a class="nav-link active" href="/"><i class="fas fa-home me-1"></i>首页</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="/recognition"><i class="fas fa-camera me-1"></i>药品识别</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="/history"><i class="fas fa-history me-1"></i>识别历史</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="/drugs"><i class="fas fa-database me-1"></i>药品管理</a>
                    </li>
                </ul>
            </div>
        </div>
    </nav>

    <!-- Hero Section -->
    <div class="hero-section">
        <div class="container">
            <h1 class="display-4 fw-bold mb-4">
                <i class="fas fa-pills me-3"></i>智能药品识别系统
            </h1>
            <p class="lead mb-5">使用人工智能技术，快速准确识别药品种类和数量</p>
            <a href="/recognition" class="btn btn-primary btn-lg">
                <i class="fas fa-camera me-2"></i>开始识别
            </a>
        </div>
    </div>

    <!-- Features Section -->
    <div class="container main-container">
        <div class="row g-4">
            <div class="col-md-4">
                <div class="card feature-card h-100" onclick="location.href='/recognition'">
                    <div class="card-body text-center p-4">
                        <div class="mb-3">
                            <i class="fas fa-camera fa-3x text-primary"></i>
                        </div>
                        <h5 class="card-title">图片识别</h5>
                        <p class="card-text">上传药品图片，AI智能识别药品种类和数量</p>
                    </div>
                </div>
            </div>
            
            <div class="col-md-4">
                <div class="card feature-card h-100" onclick="location.href='/history'">
                    <div class="card-body text-center p-4">
                        <div class="mb-3">
                            <i class="fas fa-history fa-3x text-success"></i>
                        </div>
                        <h5 class="card-title">识别历史</h5>
                        <p class="card-text">查看历史识别记录，管理识别结果</p>
                    </div>
                </div>
            </div>
            
            <div class="col-md-4">
                <div class="card feature-card h-100" onclick="location.href='/drugs'">
                    <div class="card-body text-center p-4">
                        <div class="mb-3">
                            <i class="fas fa-database fa-3x text-info"></i>
                        </div>
                        <h5 class="card-title">药品管理</h5>
                        <p class="card-text">管理药品数据库，添加和编辑药品信息</p>
                    </div>
                </div>
            </div>
        </div>
        
        <!-- Statistics Section -->
        <div class="row mt-5">
            <div class="col-12">
                <div class="card">
                    <div class="card-body">
                        <h5 class="card-title text-center mb-4">
                            <i class="fas fa-chart-bar me-2"></i>系统统计
                        </h5>
                        <div class="row text-center">
                            <div class="col-md-3 col-6">
                                <div class="mb-3">
                                    <h3 class="text-primary" id="totalRecognitions">0</h3>
                                    <small class="text-muted">总识别次数</small>
                                </div>
                            </div>
                            <div class="col-md-3 col-6">
                                <div class="mb-3">
                                    <h3 class="text-success" id="totalDrugs">0</h3>
                                    <small class="text-muted">药品种类</small>
                                </div>
                            </div>
                            <div class="col-md-3 col-6">
                                <div class="mb-3">
                                    <h3 class="text-info" id="todayRecognitions">0</h3>
                                    <small class="text-muted">今日识别</small>
                                </div>
                            </div>
                            <div class="col-md-3 col-6">
                                <div class="mb-3">
                                    <h3 class="text-warning" id="successRate">95%</h3>
                                    <small class="text-muted">识别准确率</small>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Bootstrap JS -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
    <!-- jQuery -->
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    
    <script>
        $(document).ready(function() {
            // 加载统计数据
            loadStatistics();
        });
        
        function loadStatistics() {
            // 获取识别历史统计
            $.get('/api/recognition/history')
                .done(function(data) {
                    $('#totalRecognitions').text(data.length);
                    
                    // 计算今日识别次数
                    const today = new Date().toDateString();
                    const todayCount = data.filter(item => {
                        const itemDate = new Date(item.recognitionTime).toDateString();
                        return itemDate === today;
                    }).length;
                    $('#todayRecognitions').text(todayCount);
                })
                .fail(function() {
                    console.log('无法加载识别历史统计');
                });
            
            // 获取药品统计
            $.get('/api/drugs')
                .done(function(data) {
                    $('#totalDrugs').text(data.length);
                })
                .fail(function() {
                    console.log('无法加载药品统计');
                });
        }
        
        // 添加点击动画效果
        $('.feature-card').on('click', function() {
            $(this).addClass('animate__animated animate__pulse');
            setTimeout(() => {
                $(this).removeClass('animate__animated animate__pulse');
            }, 1000);
        });
    </script>
</body>
</html>